﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using HelloNHibernate;
using NHibernate;
using NHibernate.Cfg;

namespace HelloNHibernate
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();   
            dal = new DAL();
         
        }

        private IList<Employee> employes;
        private IList<Research> researches;
        private DAL dal;

       
       private void Start()
        {
           employes = dal.LoadEmployeesFromDatabase();
           foreach (Employee e in employes)
           {
               txtBox.Text += e.Name + " " + e.Id + "\r\n";
           }
           
            
        }

       private void button1_Click(object sender, EventArgs e)
       {
           dal.CreateEmployeeAndSaveToDatabase();
       }

        
    

      

        private void btnStart_Click(object sender, EventArgs e)
        {
            Start();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtBox.Clear();
        }

        private void bntReadResearch_Click(object sender, EventArgs e)
        {
            researches=dal.LoadResearchesFromDatabase();
            foreach (Research res in researches)
            {
                txtBox.Text += res.Name + " " 
                    + res.Summary + "  " + res.AccessTime + "\r\n";
            }
        }

        private void btnAddResearch_Click(object sender, EventArgs e)
        {
            dal.CreateResearchAndSaveToDatabase();
        }

      

  

       
    }
}
